﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<nelech.Models.DBModel.Advert>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	צור פירסומת     
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
 <% var db = new nelech.Models.DBModel.nelechDBEntities(); %>
    <h2>צור פירסומת</h2>
  <%= Html.ValidationSummary() %>
    <% using (Html.BeginForm(this.Model == null ? "CreateAdvert" : "EditAdvert", "Advert", FormMethod.Post, new { enctype = "multipart/form-data" }))
       {
    %>
    <fieldset>
   
        <%
            if (Model != null)
            {
        %>
        <input type="hidden" name="id" value="<%= Model.id %>" />
        <input type="hidden" name="publish" value="1" />
        <%
            }
        %>
            <legend>שדות:</legend>
            <p>
           <label for="title">כותרת</label>
                <%= Html.TextBoxFor(model => model.name) %>
                <%= Html.ValidationMessageFor(model => model.name) %>
            </p>
            <p><label for="date">תאריך:</label><%= Html.TextBox("date") %> </p>
          <h5>צריך לשים או SWF או תמונה קטנה </h5>
           <p>
           <label for="image"> תמונה קטנה:</label>
           <input type="file" name="image"/>
            <%
                if (this.Model != null && !string.IsNullOrEmpty(this.Model.image))
                {
                    Response.Write(string.Format("<img src='{0}' />", this.Model.image));%>
                  
                    <%: Html.ActionLink("מחק", "RemoveAdvertFile", new { id = Model.id, fileType= "image"})%>
              <%  }
            %>
           </p>
            <p>
           <label for="image"> תמונה גדולה:</label>
           <input type="file" name="bigImg"/>
            <%
           if (this.Model != null && !string.IsNullOrEmpty(this.Model.bigImg))
           {
               Response.Write(string.Format("<img src='{0}' width='200px'/>", this.Model.bigImg));%>
                 <%: Html.ActionLink("מחק", "RemoveAdvertFile", new { id = Model.id, fileType= "bigImg"})%>
          <% }
         
            %>
           </p>

              <p>
           <label for="pdf">קובץ swf:</label>
           <input type="file" name="swf"/>
            <%
           if (this.Model != null && !string.IsNullOrEmpty(this.Model.swf))
                {
                    Response.Write(this.Model.swf);%>
               <%: Html.ActionLink("מחק", "RemoveAdvertFile", new { id = Model.id, fileType= "swf"})%>
          <% }
                     %>
           </p>

              <p>
           <label for="pdf">קובץ pdf מצורף:</label>
           <input type="file" name="pdf"/>
            <%
                if (this.Model != null && !string.IsNullOrEmpty(this.Model.pdf))
                {
                    Response.Write(this.Model.pdf);%>
                 <%: Html.ActionLink("מחק", "RemoveAdvertFile", new { id = Model.id, fileType= "pdf"})%>
          <% }
                     %>
           </p>
            
           <p>
           <label for="link">קישור:</label>
           <%= Html.TextBox("link") %>
           </p>
           <p><label>מיקום וגודל:</label>    <%
                foreach (var place in db.AdvertPlace)
                {
                    Response.Write(Html.CheckBox("place" + place.id.ToString(), Model != null && Model.AdvertPlace != null && Model.AdvertPlace.Contains(place, new nelech.Views.Shared.Code.AdvertComparer())));
                    Response.Write(place.place);
                }
            %></p>
             <p><label>אזור:</label>    <%
                foreach (var region in db.Regeon)
                {
                    Response.Write(Html.CheckBox("region" + region.id.ToString(), Model != null && Model.Regeon != null && Model.Regeon.Contains(region, new nelech.Views.Shared.Code.RegionComparer())));
                    Response.Write(region.text);
                }
            %></p>
            <p>
                <input type="submit" value="שמור" />
            </p>
        </fieldset>

    <% } %>

    <div>
        <%=Html.ActionLink("חזרה לרשימה", "ListAdvert") %>
    </div>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
